namespace DesignPattern.Creational.Prototype
{
    public class PrototypePattern
    {
        public static void Test()
        {
            {
                System.Console.WriteLine("test shallow clone...");

                var zhangsan = new Student
                {
                    Id = 1,
                    Name = "张三",
                    Class = new Class
                    {
                        ClassId = 1,
                        ClassName = "小一班"
                    }
                };

                System.Console.WriteLine($"zhangsan's id is {zhangsan.Id}, name is {zhangsan.Name}, {zhangsan.Class}");

                var lisi = zhangsan.ShallowClone();
                System.Console.WriteLine($"shallow clone from zhangsan, lisi's id is {lisi.Id}, name is {lisi.Name}, {lisi.Class}");

                zhangsan.Id = 2;
                zhangsan.Name = "张三三";
                zhangsan.Class.ClassId = 2;
                zhangsan.Class.ClassName = "小小一班";
                System.Console.WriteLine($"modify zhangsan's id to {zhangsan.Id}, name to {zhangsan.Name}, class to {zhangsan.Class}, then lisi's id is {lisi.Id}, name is {lisi.Name}, {lisi.Class}");
            }

            {
                System.Console.WriteLine("test deep clone...");

                var zhangsan = new Student
                {
                    Id = 1,
                    Name = "张三",
                    Class = new Class
                    {
                        ClassId = 1,
                        ClassName = "小一班"
                    }
                };

                System.Console.WriteLine($"zhangsan's id is {zhangsan.Id}, name is {zhangsan.Name}, {zhangsan.Class}");

                var lisi = zhangsan.DeepClone();
                System.Console.WriteLine($"deep clone from zhangsan, lisi's id is {lisi.Id}, name is {lisi.Name}, {lisi.Class}");

                zhangsan.Id = 2;
                zhangsan.Name = "张三三";
                zhangsan.Class.ClassId = 2;
                zhangsan.Class.ClassName = "小小一班";
                System.Console.WriteLine($"modify zhangsan's id to {zhangsan.Id}, name to {zhangsan.Name}, class to {zhangsan.Class}, then lisi's id is {lisi.Id}, name is {lisi.Name}, {lisi.Class}");
            }
        }
    }
}